package com.easylinkin.linkappapi.ruleengine.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.easylinkin.linkappapi.device.entity.Device;
import com.easylinkin.linkappapi.ruleengine.entity.RuleEngine;
import com.easylinkin.linkappapi.ruleengine.entity.RuleTrigger;
import java.util.List;
import java.util.Set;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 规则触发器 服务类
 * </p>
 *
 * @author TongJie
 * @since 2020-08-24
 */
public interface RuleTriggerService extends IService<RuleTrigger> {

    @Transactional(rollbackFor = Exception.class)
    void add(RuleTrigger ruleTrigger);

    List<RuleTrigger> getRuleTriggers(RuleTrigger ruleTrigger);

    IPage<RuleTrigger> getRuleTriggers(Page page, RuleTrigger ruleTrigger);

    RuleTrigger getRuleTrigger(String id);

//    void updateRuleTrigger(RuleTrigger ruleTrigger);

    void deleteBatch(List<RuleTrigger> ruleTriggerList);

    List<RuleTrigger> getRuleTriggersAndExpressions(RuleTrigger ruleTrigger);

    void disableByTenantId(String tenantId);

    void updateStatusForType3ByRuleEngineChange(RuleEngine ruleEngine);

    /**
     * 查找满足触发器的条件 规则引擎
     *
     * @param device 设备 vo
     * @param data
     * @return 满足条件的规则引擎的id集合
     */
    Set<String> getMeetRuleTriggerRuleEngineIds(Device device, Object data);

    /**
     * 检查满足触发器
     *
     * @param device 设备vo
     * @param ruleTrigger 触发器 vo
     */
    boolean checkMeetRuleTrigger(Device device, RuleTrigger ruleTrigger, Object data);
}
